<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('商家基本信息列表')" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>商家名称：</label>
                                <input type="text" name="storeName"/>
                            </li>
                            <li>
                                <label>业务员姓名：</label>
                                <div class="col-sm-2">
                                    <select class="form-control" name="managerId">
                                        <option value="">所有</option>
                                        <option th:each="item:${managerInfoList}" th:value="${item.userId}" th:text="${item.username}"></option>
                                    </select>
                                </div>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="prod:storeInfo:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="prod:storeInfo:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="prod:storeInfo:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
<!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="prod:storeInfo:export">-->
<!--                    <i class="fa fa-download"></i> 导出-->
<!--                </a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
     <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('prod:storeInfo:edit')}]];
        var removeFlag = [[${@permission.hasPermi('prod:storeInfo:remove')}]];
        var prefix = ctx + "prod/storeInfo";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "商家基本信息",
                columns: [
                //     {
                //     checkbox: true
                // },
                // {
                //     field: 'id',
                //     title: '',
                //     visible: false
                // },
                {
                    field: 'storeName',
                    title: '商家名称',
                    formatter: function (value, row, index){
                        return row.storeName + ' [' + row.id + ']';
                    }
                },
                {
                    field: 'storeDesc',
                    title: '商家介绍',
                    formatter: function (value, row){
                        if (value == undefined || value == ''){
                            return '-';
                        }
                        return '<span style="color: darkgreen; border-bottom: 1px solid" onclick="showAdminInfo(\''+row.storeDesc+'\')">详情</span>'
                    }
                },
                {
                    field: 'storeLogo',
                    title: '商家logo',
                    formatter: function (value,row,index){
                        return $.table.imageView(row.storeLogo, 500, 500)
                    }
                },
                // {
                //     field: 'companyName',
                //     title: '公司名称'
                // },
                // {
                //     field: 'companyUser',
                //     title: '联系人'
                // },
                // {
                //     field: 'companyMobile',
                //     title: '联系电话'
                // },
                    {
                        field: 'status',
                        title: '状态',
                        formatter: function (value, row) {
                            return statusTools(row);
                        }
                    },
                // {
                //     field: 'managerId',
                //     title: '业务员ID'
                // },
                {
                    field: 'managerName',
                    title: '业务员姓名'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });


        /* 用户状态显示 */
        function statusTools(row) {
            if (row.status == 0) {
                return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.id + '\')"></i> ';
            } else {
                return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.id + '\')"></i> ';
            }
        }

        /* 用户管理-停用 */
        function disable(id) {
            $.modal.confirm("确认要停用吗？", function () {
                $.operate.post(prefix + "/changeStatus", {"id": id, "status": 0});
            })
        }

        /* 用户管理启用 */
        function enable(id) {
            $.modal.confirm("确认要启用吗？", function () {
                $.operate.post(prefix + "/changeStatus", {"id": id, "status": 1});
            })
        }


         function showAdminInfo(storeDesc) {
             var content = storeDesc
             $.modal.alert(content,modal_status.MESSAGE, '商家介绍',);
         }



    </script>
</body>
</html>